<?php
$version = Zend_Registry::get('version');
$this->pageForm->setEditor($this->serverUrl().$this->baseUrl());
$this->pageForm->getEditor();	
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/tree/javascripts/jquery.treeTable.js');

$frontController = Zend_Controller_Front::getInstance();
$param_group_id = $frontController->getRequest()->getParam('group_id');
?>

<script type="text/javascript">
$(document).ready(function() {
	 categoryTreeGen();
	 imageThumbnil();
	 floatingbar('#floatingbar',"#button_top_bar",null);
	 deleteFiles("<?php echo $this->translator->translator('gallery_img_main', '', 'Gallery'); ?>", "<?php echo $this->translator->translator('gallery_img_related', '', 'Gallery'); ?>", "<?php echo $this->url( array('module' => 'Portfolio','controller' => 'frontend', 'action'     => 'remove' ), 'adminrout',    true) ?>", "<?php echo $this->translator->translator('common_delete_title'); ?>");
	 
	 $("#page_date").datepicker({
			showOn: 'button',
			buttonImage: 'application/modules/Administrator/layouts/scripts/images/common/calendar.png',
			buttonImageOnly: true,
			showAnim: 'slide',
			buttonText: 'Calender',
			dateFormat:'yy-mm-dd h:i:s',
			autoSize:false,
			showButtonPanel:false,
			changeMonth: true,
			changeYear: true
		});
	
	 
	function openMsgDialog(msg)
	{
		$('#dialog_msg').html(msg).dialog({
			autoOpen: true,
			modal: true,
			show: 'explode',
			resizable: true,				
			buttons: [{ text: "<?php echo html_entity_decode($this->translator->translator('common_ok'), ENT_QUOTES, 'UTF-8'); ?>", click: function() { $(this).dialog('option', 'hide', 'explode').dialog("close"); } } ],
			open: function(event, ui)
				 {
					setTimeout(function() 
					{									
						if($('#' + event.target.id).dialog('isOpen'))
						{
							$('#' + event.target.id).dialog('option', 'hide', 'explode').dialog('close');										
						}
					}, 10000);
				  }
		});
	}
	 
	$("#upload-form").dialog({
		autoOpen: false,
		width: 760,
		height: 610,
		show: 'fade',			
		modal: true
	});	

	$('a.upload_btn').click(function() {
		var self = this;
		$("#i-upload-form").attr("src", '');
		
		var group_id = $("#group_id").val();
		$('input[name="primary_id_field_value"]').val(group_id);
		
		var rel = $(self).attr('rel');
		$('input[name="file_path_field"]').val('file_path_'+rel);
			
		var file_suffix =  rel;			
		var file_content = $('#'+file_suffix).val();		
		$('input[name="file_content"]').val(file_content);		
		$('input[name="primary_file_field"]').val(file_suffix);	
		
		if(group_id != null && group_id != "")
		{
			$("#popupForm").attr("action", "<?php echo $this->url( array('module' => 'Portfolio','controller' => 'frontend', 'action' => 'manager' ), 'adminrout',    true) ?>");			
			$('#upload-form').dialog('open');
			$('#popupForm').submit();
		}
		else
		{
			msg = '<?php echo $this->translator->translator("group_id_selected_err"); ?>';
			openMsgDialog(msg);
		}
	});	
	
	$('a.select_file_btn').click(function() {			
		var currentIFrame = $('#i-upload-form');
		var selected_files = currentIFrame.contents().find("input[name='selected_files']").val();
		var primary_file_field = currentIFrame.contents().find("input[name='primary_file_field']").val();
		var file_path	=	currentIFrame.contents().find("input[name='file_path']").val();
		var selected_files_arr = (selected_files != '') ? selected_files.split(',') : new Array();	
		if(selected_files_arr.length == '0')
		{
			var msg = '<?php echo $this->translator->translator("insert_selected_file_err"); ?>';				
			openMsgDialog(msg);
		}
		else
		{
			var img_code = '';
			var file_name = '';
			for(var i=0;i < selected_files_arr.length;i++)
			{
				var ext = getFileExtension(selected_files_arr[i]);
				var img_path = '';
				switch(ext)
				{
					case 'flv':
					case 'swf':
					case 'FLV':
					case 'SWF':
						img_path = 'application/modules/Administrator/layouts/scripts/images/common/flash.png';
						break;
					case 'mp3':
					case 'MP3':
						img_path = 'application/modules/Administrator/layouts/scripts/images/common/mp3.png';
						break;
					case 'avi':
					case 'wmv':
					case 'wma':
					case 'WMA':
					case 'AVI':
					case 'WMV':
						img_path = 'application/modules/Administrator/layouts/scripts/images/common/avi_thumb.png';
						break;
					case 'pdf':
					case 'doc':
					case 'docx':
					case 'xls':
					case 'xlsx':
					case 'ppt':
					case 'pptx':
					case 'PDF':
					case 'DOC':
					case 'DOCX':
					case 'XLS':
					case 'XLSX':
					case 'PPT':
					case 'PPTX':
						img_path = 'application/modules/Administrator/layouts/scripts/images/common/extImages/'+ext+'.png';
						break;
					default:
						img_path = file_path +'/'+ selected_files_arr[i]; 
						break;
				}
				var checked = (i == 0)? ' checked="checked" ' : '';
				var img_type = 	''; 
															
				var primary = ''; 
										
				var del_link = '<a href="javascript:void(0)" class="delete_image_lnk" rel="'+selected_files_arr[i]+'"><?php echo html_entity_decode($this->translator->translator("common_delete"), ENT_QUOTES, "UTF-8"); ?></a>'+primary;
				img_code += '<div class="upload-img box">'+img_type+'<span><span class="thumb"><img src="'+img_path+'" width="45" height="35" class="bdr" /></span><br /><br />&nbsp;'+del_link+'&nbsp;&nbsp;&nbsp;</span></div>';
				file_name = (i == 0)? selected_files_arr[i] : file_name+','+selected_files_arr[i];
				break;					
			}			
			var file_suffix = (primary_file_field == 'page_thumb') ? primary_file_field : 'page_file';		
			$('#selected_file_'+file_suffix).html(img_code);		
			$('#'+file_suffix).val(file_name);		
			$("#i-upload-form").attr("src", ''); 						
			$("#upload-form").dialog('option','hide','explode').dialog('close');				
			deleteFiles("<?php echo $this->translator->translator('gallery_img_main', '', 'Gallery'); ?>", "<?php echo $this->translator->translator('gallery_img_related', '', 'Gallery'); ?>", "<?php echo $this->url( array('module' => 'Portfolio','controller' => 'frontend', 'action'     => 'remove' ), 'adminrout',    true) ?>", "<?php echo $this->translator->translator('common_delete_title'); ?>");	
			imageThumbnil();
		}
	});
	
	$('a.close_dialog_btn').click(function() {		 
		$("#i-upload-form").attr("src", '');  
		$("#upload-form").dialog('option','hide','explode').dialog('close');			
	});
	
	$('a.reset_btn').click(function() {			
		 resetFields();	
		 removeError();
		 imageThumbnil();	
	});
	
	function resetFields()
	{
		$( "form" )[ 0 ].reset();
		$('#selected_file_page_thumb').html('<div class="upload-img box"><span><span class="thumb"><img src="data/frontImages/news/page_thumb/<?php echo $this->pageForm->page_thumb->getValue(); ?>" width="45" height="35" class="bdr"/></span><br /><br /><a href="javascript:void(0)" class="delete_image_lnk" field_name="page_thumb" file_name="<?php echo $this->pageForm->page_thumb->getValue(); ?>" file_path="data/frontImages/gallery/page_thumb" rel="<?php echo $this->pageForm->page_thumb->getValue(); ?>">&nbsp;<?php echo $this->translator->translator('common_delete'); ?></a>&nbsp;&nbsp;</span></div>');
		$('#page_parent').val('<?php echo $this->pageForm->category_id->getValue(); ?>');
		$('#page_thumb').val('<?php echo $this->pageForm->page_thumb->getValue(); ?>');
		$('#categoryTree').html('<?php echo addslashes($this->categoryTree); ?>');
		$('#dataId').html('<?php echo addslashes($this->category_name)." (".$this->pageForm->category_id->getValue().")"; ?>');			
		$('a.back_btn_link').attr('href','<?php echo $this->url( array("module" => "News","controller" => "backendpro", "action"  => "list" ,"group_id" => $param_group_id), "adminrout",    true) ?>');
		categoryTreeGen();
		deleteFiles("<?php echo $this->translator->translator('gallery_img_main', '', 'Gallery'); ?>", "<?php echo $this->translator->translator('gallery_img_related', '', 'Gallery'); ?>", "<?php echo $this->url( array('module' => 'Portfolio','controller' => 'frontend', 'action'     => 'remove' ), 'adminrout',    true) ?>", "<?php echo $this->translator->translator('common_delete_title'); ?>");
	}
	
	function removeError()
	{
		$('#actionMessage').html('');
		
		var filename = '';
		var filevalue = '';		
		$.each($('form').serializeArray(), function(i, field) {	
		  if(field.name.match(/\[\]$/))
		  {
			  var filearr = field.name.split('[]');
			  filename = filearr[0];					
		  }
		  else
		  {
			  filename 	= 	field.name;
		  } 			
		  $('#'+filename).removeClass('ui-state-error');
		  $('#'+filename+'_err').html('');									
		});				
	}
	
	function addError(key,errMsg)
	{
		var err_id = key+'_err';
		var field_name = key;
		$('#'+field_name).addClass('ui-state-error');
		$('#'+err_id).append(errMsg);
	}
	
	function openLoaderDialog()
	{
		$('#dialog_container').dialog({
					autoOpen: true,
					modal: true,
					show: 'explode',
					resizable: false,				
					open: function(event, ui)
						 {
						 	$("#progressbar").progressbar({
								value:100
				
							});							
						  }
				});
	}
	
	function closeLoaderDialog()
	{
		$('#dialog_container').dialog('option','hide','explode').dialog('close');
	}
	
	function getFormData()
	{
		var fieldObj = {};
		var filename = '';
		var filevalue = '';
		$.each($('form').serializeArray(), function(i, field) {	
			if(field.name.match(/\[\]$/))
			{
				var filearr = field.name.split('[]');
				filename = filearr[0];
				filevalue = $('#'+filename).val();
				if($('input[name="'+filename+'[]"]').is(':checkbox'))
				{
					var val_arr = [];
					$('input[name="'+filename+'[]"]:checkbox:checked').each(function(i){
					 val_arr[i] = $(this).val();
					});
					filevalue = (val_arr[0] != null) ? val_arr.join(',') : null;					
				}
			}
			else
			{
				filename 	= 	field.name;
				filevalue 	= 	field.value;
			}			
			fieldObj[filename] = (tinyMCE.get(filename)) ? tinyMCE.get(filename).getContent() : filevalue;			
		});
		return fieldObj;
	}
	
	$('a.edit_page_btn').click(function() {			
		var formData = getFormData();
			formData.id  = '<?php echo $this->id ; ?>';				
	$.ajax({
		url: "<?php echo $this->url( array('module' => 'News','controller' => 'Backendpro', 'action'     => 'edit' ), 'adminrout',    true) ?>",
			type: 'POST',
			data: formData,
			beforeSend: function(){						
						removeError();
						openLoaderDialog();				
					 },
			success: function(response){
				//alert(response);					
				var json_arr = eval("("+response+")");										
				if(json_arr.status == 'ok')
				{
					$('#actionMessage').html(succMsgDesign(json_arr.msg));	
					refreshCategoryTree();											
				}
				else if(json_arr.status == 'errV')
				{
					$('#actionMessage').html(errMsgDesign("<?php echo $this->translator->translator('common_err'); ?>"));
											
					for(var i= 0; i < json_arr.msg.length; i++)
					{
						focusFirst(json_arr.msg[i].key, json_arr.msg[i].value, i);
						addError(json_arr.msg[i].key,json_arr.msg[i].value);							
					}
				}
				else
				{
					$('#actionMessage').html(errMsgDesign(json_arr.msg));
				}
				closeLoaderDialog();
			},
			error: function(xhr, status, error){
				closeLoaderDialog();
				var msg = "Error! " + xhr.status + " " + error;
				$('#actionMessage').html(errMsgDesign(msg));
			}
	});
});
	

/***********************************Get News Group***************************************/
	$('select.page_select_group').change(function() {		
		$('#group_id_loader').html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" border="0" height="15" class="left-float"/>');
		var group_id = $('#group_id').val();
		if(group_id != '')
		{
			$('a.back_btn_link').attr('href','News/backendpro/list/group_id/'+group_id);
			$.ajax({
				url: "<?php echo $this->url( array('module' => 'News','controller' => 'Backend', 'action'     => 'newsgroup' ), 'adminrout',    true) ?>",
			  	type: 'POST',
			  	data: { grp_id: group_id },
				success: function(response){
					//alert(response);
					var json_arr = eval("("+response+")");
					if(json_arr.status == 'ok')
					{
						var tree = '<table class="example" id="dnd-example">'+
										'<tbody ><tr id="node-0">'+
										 '<td>'+
											'<span class="folder"><?php echo $this->translator->translator("news_tree_root"); ?></span>'+
										'</td>'+
									'</tr>';
							tree += json_arr.newsGroup+'</tbody></table>';
						$('#categoryTree').html(tree);
						categoryTreeGen();
					}
					else
					{
						var tree = '<table class="example" id="dnd-example">'+
										'<tbody ><tr id="node-0">'+
										 '<td>'+
											'<span class="folder"><?php echo $this->translator->translator("news_tree_root"); ?></span>'+
										'</td>'+
									'</tr>';
							tree += '</tbody></table>';
						$('#categoryTree').html(tree);
						categoryTreeGen();						
					}
					$('#group_id_loader').html('');
					$('#group_id_err').html('');
				}
			});
		}
		else
		{
			var tree = '<table class="example" id="dnd-example">'+
										'<tbody ><tr id="node-0">'+
										 '<td>'+
											'<span class="folder"><?php echo $this->translator->translator("news_tree_root"); ?></span>'+
										'</td>'+
									'</tr>';
				tree += '</tbody></table>';
			$('#categoryTree').html(tree);
			categoryTreeGen();
			$('#group_id_err').html('');
			$('#group_id_loader').html('');
			$('a.back_btn_link').attr('href','News/backendpro/list');
		}		
	});
	
		
	
});
/********************************News Tree Function*******************************************/
function categoryTreeGen()
{
	$(".example").treeTable({
	  initialState: "expanded"
	});
	
	// Drag & Drop Example Code
	$("#dnd-example .file, #dnd-example .folder").draggable({
	  helper: "clone",
	  opacity: .75,
	  refreshPositions: true,
	  revert: "invalid",
	  revertDuration: 300,
	  scroll: true
	});
	
	
	$("#dnd-example .folder").each(function() {
	  $($(this).parents("tr")[0]).droppable({
		accept: ".file, .folder",
		drop: function(e, ui) { 
			var fieldObj = {};
				fieldObj.id = $(ui.draggable).parents("tr")[0].id;
				fieldObj.to =	this.id;
			var url = "<?php echo $this->url( array('module' => 'News','controller' => 'Backend', 'action'     => 'parent' ), 'adminrout',    true) ?>";
		  $($(ui.draggable).parents("tr")[0]).postDataTo(this,fieldObj,url); 
		  $($(ui.draggable).parents("tr")[0]).appendBranchTo(this);
		  
		  // Issue a POST call to send the new location (this) of the 
		  // node (ui.draggable) to the server.
		
		},
		hoverClass: "accept",
		over: function(e, ui) {
		  if(this.id != $(ui.draggable.parents("tr.parent")[0]).id && !$(this).is(".expanded")) {
			$(this).expand();
		  }
		}
	  });
	});
	
	 $("#dnd-example .file").each(function() {
	  $($(this).parents("tr")[0]).droppable({
		accept: ".file, .folder",
		drop: function(e, ui) { 
		var fieldObj = {};
				fieldObj.id = $(ui.draggable).parents("tr")[0].id;
				fieldObj.to =	this.id;
			var url = "<?php echo $this->url( array('module' => 'News','controller' => 'Backend', 'action'     => 'parent' ), 'adminrout',    true) ?>";
		  $($(ui.draggable).parents("tr")[0]).postDataTo(this,fieldObj,url); 
		  $($(ui.draggable).parents("tr")[0]).appendBranchTo(this);
		  
		  // Issue a POST call to send the new location (this) of the 
		  // node (ui.draggable) to the server.
		},
		hoverClass: "accept",
		over: function(e, ui) {
		  if(this.id != $(ui.draggable.parents("tr.parent")[0]).id && !$(this).is(".expanded")) {
			$(this).expand();
		  }
		}
	  });
	});
	
	// Make visible that a row is clicked
	$("table#dnd-example tbody tr").mousedown(function() {
	  $("tr.selected").removeClass("selected"); // Deselect currently selected rows
	  $(this).addClass("selected");
	});
	
	// Make sure row is selected when span is clicked
	$("table#dnd-example tbody tr span").mousedown(function() {
		var node_id = $(this).parents("tr")[0].id.substr(5);
		var node_name = $(this).html()+' ('+node_id+')';
		$('#page_parent').val(node_id);
		$('#dataId').html(node_name);
	  $($(this).parents("tr")[0]).trigger("mousedown");
	});
}


/********************************Refresh News Tree*******************************************/
function refreshCategoryTree()
{
	var group_id = $('#group_id').val();
	var page_parent = $('#page_parent').val();
	if(group_id != '')
	{
		$.ajax({
			url: "<?php echo $this->url( array('module' => 'News','controller' => 'Backend', 'action'     => 'categorytree' ), 'adminrout',    true) ?>",
			type: 'POST',
			data: { grp_id: group_id, parent: page_parent },
			success: function(response){				
				var json_arr = eval("("+response+")");
				if(json_arr.status == 'ok')
				{
					var tree = '<table class="example" id="dnd-example">'+
									'<tbody ><tr id="node-0">'+
									 '<td>'+
										'<span class="folder"><?php echo $this->translator->translator("news_tree_root"); ?></span>'+
									'</td>'+
								'</tr>';
						tree += json_arr.categoryTree+'</tbody></table>';
					$('#categoryTree').html(tree);
					categoryTreeGen();
				}
				else
				{
					var tree = '<table class="example" id="dnd-example">'+
										'<tbody ><tr id="node-0">'+
										 '<td>'+
											'<span class="folder"><?php echo $this->translator->translator("news_tree_root"); ?></span>'+
										'</td>'+
									'</tr>';
							tree += '</tbody></table>';
					$('#categoryTree').html(tree);
					categoryTreeGen();
				}					
			}
		});
	}
	else
	{
		var tree = '<table class="example" id="dnd-example">'+
										'<tbody ><tr id="node-0">'+
										 '<td>'+
											'<span class="folder"><?php echo $this->translator->translator("news_tree_root"); ?></span>'+
										'</td>'+
									'</tr>';
							tree += '</tbody></table>';
		$('#categoryTree').html(tree);
		categoryTreeGen();			
	}	
}

/************************************************IMAGE THUMBNIL************************************************/
function imageThumbnil()
{	
	$("span.thumb").hover(function() {
		$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
		$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
			.animate({
				marginTop: '-110px', /* The next 4 lines will vertically align this image */ 
				marginLeft: '-110px',
				top: '50%',
				left: '50%',
				width: '174px', /* Set new width */
				height: '174px', /* Set new height */
				padding: '20px'
			}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
	
		} , function() {
		$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
		$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
			.animate({
				marginTop: '4px', /* Set alignment back to default */
				marginLeft: '0',
				top: '0',
				left: '0',
				width: '30px', /* Set width back to default */
				height: '20px', /* Set height back to default */
				padding: '5px'
			}, 400);
	});
}

function getFileExtension(filename)
{
	return filename.replace(/^.*?\.([a-zA-Z0-9]+)$/, "$1");
}

function calender(id)
{	
	$("#"+id).datepicker({
		showOn: 'button',
		buttonImage: 'application/modules/Administrator/layouts/scripts/images/common/calendar.png',
		buttonImageOnly: true,
		monthNamesShort:<?php echo $this->translator->translator("common_calender_monthNamesShort"); ?>,
		monthNames:<?php echo $this->translator->translator("common_calender_monthNames"); ?>,
		dayNamesMin:<?php echo $this->translator->translator("common_calender_dayNamesMin"); ?>,
		showAnim: 'slide',
		buttonText: 'Calender',
		dateFormat:'yy-mm-dd',
		autoSize:false,
		showButtonPanel:false,
		changeMonth: true,
		changeYear: true
	});
	
	$("img[class='ui-datepicker-trigger']").each(function()
	 { 
	  	$(this).attr('style', '');
	 });
	 
}

</script>
<div id="container">
<?php if (!$this->allow()) : ?>
	<div class="grid_12 t_a_bottom">
		<?php echo $this->translator->translator('Member_Access_deny_desc'); ?>
	</div>
<?php else : ?>

<div class="title-container">
	<div class="news-edit"><h1><?php echo $this->translator->translator('news_page_edit_page_name'); ?></h1></div>
    
    <div class="button-container">
        <span class="button ui-widget-content-1"><a href="<?php echo $this->url( array('module' => 'News','controller' => 'Backendpro', 'action'     => 'list','group_id' => $param_group_id), 'adminrout',    true) ?>" class="back_btn_link"><span class="icon back"><?php echo $this->translator->translator('common_back'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript:  void(0);" class="reset_btn"><span class="icon reset"><?php echo $this->translator->translator('common_reset'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript: void(0);" class="edit_page_btn"><span class="icon save"><?php echo $this->translator->translator('common_save'); ?></span></a></span>
    </div>
</div>

<div class="content-container">
	<div id="sidebar-inner">
    	<div id="nav">
    		<div class="nav-header"><div class="nav-title"><?php echo $this->translator->translator('news_tree'); ?></div></div>
    		<div id="categoryTree" class="nav-body treebody" >
           		<?php echo $this->categoryTree; ?>
            </div>
       	</div>
    </div>
    
    <div id="content-inner">
    	<div id="actionMessage"></div>
        <div id="button_top_bar"></div>
        <form name="formCategory" id="formCategory" method="post" >
        		<div id="generalInfo">
            	<fieldset class="fieldset">
                	<legend class="legend"><?php echo $this->translator->translator('news_page_page_info'); ?></legend>
                    <div class="form">
                    	<div class="form-row">
                        	<div class="label">
                           		<?php echo $this->pageForm->page_name->getLabel();  if($this->pageForm->page_name->isRequired()){?><span class="required">*</span><?php } ?>
                          	</div>
                            
                          	<div class="field">
                            	<?php echo $this->pageForm->page_name;  ?>
								<div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($this->pageForm->page_name->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                <div class="input-errors" id="page_name_err"></div>
                            </div>
						</div>
                        
                        <div class="form-row">
                        	<div class="label">
                           		<?php echo $this->pageForm->page_title->getLabel(); if($this->pageForm->page_title->isRequired()){ ?><span class="required">*</span><?php } ?>
                          	</div>
                            
                          	<div class="field">
                            	<?php echo $this->pageForm->page_title; ?>
								<div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($this->pageForm->page_title->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                <div class="input-errors" id="page_title_err"></div>
                            </div>
						</div>
                        
                        <div class="form-row">
                        	<div class="label">
                           		<?php echo $this->pageForm->page_date->getLabel();  if($this->pageForm->page_date->isRequired()){?><span class="required">*</span><?php } ?>
                          	</div>
                            
                          	<div class="field">
                            	<?php echo $this->pageForm->page_date; ?>
								<div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($this->pageForm->page_date->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                <div class="input-errors" id="page_date_err"></div>
                            </div>
						</div>
                        
                        <div class="form-row">
                        	<div class="label">
                           		<?php echo $this->pageForm->group_id->getLabel(); if($this->pageForm->group_id->isRequired()){ ?><span class="required">*</span><?php } ?>
                          	</div>
                            
                          	<div class="field">
                            	<div class="left-float"><?php echo $this->pageForm->group_id; ?></div><span id="group_id_loader"></span>
								<div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($this->pageForm->group_id->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                <div class="input-errors" id="group_id_err"></div>
                            </div>
						</div>
                        
                        <div class="form-row">
                        	<div class="label">
                           		<?php echo $this->pageForm->category_id->getLabel(); ?>
                          	</div>
                            
                          	<div class="field">
                            	<span id="dataId"><?php echo $this->escape($this->category_name)." (".$this->pageForm->category_id->getValue().")"; ?></span><?php echo $this->pageForm->category_id; ?>
                            </div>
						</div>
                        
                        <div class="form-row">
                        	<div class="label">
                           		<?php echo $this->pageForm->page_thumb->getLabel(); if($this->pageForm->page_thumb->isRequired()){ ?><span class="required">*</span><?php } ?>
                          	</div>
                            
                          	<div class="field">
                            	<div class="upload-img">
                                	<span class="button ui-widget-content-1"><a href="javascript:  void(0);" class="upload_btn" rel="page_thumb"><span class="icon upload"><?php echo $this->translator->translator('common_upload'); ?></span></a></span>
                                    <div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($this->pageForm->page_thumb->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                </div>
                            	<?php echo $this->proForm->product_file;  ?>&nbsp;&nbsp;<span id="selected_file_product_file"><?php echo $assign_product_file; ?></span>
                                <?php echo $this->pageForm->page_thumb; ?>&nbsp;&nbsp;
                                <span id="selected_file_page_thumb">
                                        <?php
                                        $utility = new Eicra_File_Utility();
                                        $file['ext'] = $utility->GetExtension($this->pageForm->page_thumb->getValue());
                                        if($file['ext'] == 'jpg' || $file['ext'] == 'png' || $file['ext'] == 'gif' || $file['ext'] == 'bmp')
                                            {
                                        ?>
                                        <div class="upload-img box"><span><span class="thumb"><img src="data/frontImages/news/page_thumb/<?php echo $this->pageForm->page_thumb->getValue(); ?>" width="45" height="35" class="bdr" /></span><br /><br /><a href="javascript:void(0)" class="delete_image_lnk" field_name="page_thumb" file_name="<?php echo $this->pageForm->page_thumb->getValue(); ?>" file_path="data/frontImages/gallery/page_thumb" rel="<?php echo $this->pageForm->page_thumb->getValue(); ?>">&nbsp;<?php echo $this->translator->translator('common_delete'); ?></a>&nbsp;&nbsp;</span></div>									
                                        <?php
                                            }
                                        else
                                            {
                                        ?>
                                        <div class="upload-img box"><span><span class="thumb"><img src="<?php echo $this->baseUrl().'/'; ?>application/modules/Administrator/layouts/scripts/images/common/all_file_thumb.png" width="45" height="35" class="bdr" /></span><br /><br /><a href="javascript:void(0)" class="delete_image_lnk" field_name="page_thumb" file_name="<?php echo $this->pageForm->page_thumb->getValue(); ?>" file_path="data/frontImages/gallery/page_thumb" rel="<?php echo $this->pageForm->page_thumb->getValue(); ?>">&nbsp;<?php echo $this->translator->translator('common_delete'); ?></a>&nbsp;&nbsp;</span></div>	
                                        <?php
                                            }
                                        ?>
                               	</span>
                                <div class="input-errors" id="page_thumb_err"></div>
                            </div>
                       	</div>
                        
                        <div class="form-row">
                        	<div class="label">
                           		<?php echo $this->pageForm->page_desc->getLabel(); if($this->pageForm->page_desc->isRequired()){ ?><span class="required">*</span><?php } ?>
                          	</div>
                            
                          	<div class="field">
                            	<div class="editor"><?php echo $this->pageForm->page_desc; ?></div>
                                <div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($this->pageForm->page_desc->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                <span id="loaderLink"><a href="javascript:void(0);" onClick="loadTinyMCE('page_desc');"><img src="application/modules/Administrator/layouts/scripts/images/common/editors.gif" border="0" title="<?php echo $this->translator->translator('common_editor_open'); ?>" alt="<?php echo $this->translator->translator('common_editor_open'); ?>" /></a></span>
                                <div class="input-errors" id="page_desc_err"></div>
                            </div>
						</div>
                	</div>
					</fieldset>
				</div>
                
                	<fieldset class="fieldset">
                        <legend class="legend"><?php echo $this->translator->translator('news_page_related_items'); ?></legend>
                        <div class="form">
                            <div class="form-row">
                                <div class="label">
                                    <?php echo $this->pageForm->related_items->getLabel();  if($this->pageForm->related_items->isRequired()){ ?><span class="required">*</span><?php } ?>
                                </div>
                                
                                <div class="field">
                                    <?php  echo $this->pageForm->related_items;  ?>
                                    <div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($this->pageForm->meta_title->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                    <div class="input-errors" id="related_items_err"></div>
                                </div>
                            </div>
                        </div>
                   	</fieldset>
                    
                    <fieldset class="fieldset last">
                        <legend class="legend"><?php echo $this->translator->translator('news_page_page_meta'); ?></legend>
                        <div class="form">
                            <div class="form-row">
                                <div class="label">
                                    <?php echo $this->pageForm->meta_title->getLabel(); if($this->pageForm->meta_title->isRequired()){ ?><span class="required">*</span><?php } ?>
                                </div>
                                
                                <div class="field">
                                    <?php  echo $this->pageForm->meta_title;  ?>
                                    <div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($this->pageForm->meta_title->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                    <div class="input-errors" id="meta_title_err"></div>
                                </div>
                            </div>
                            
                            <div class="form-row">
                                <div class="label">
                                    <?php echo $this->pageForm->meta_keywords->getLabel(); if($this->pageForm->meta_keywords->isRequired()){ ?><span class="required">*</span><?php } ?>
                                </div>
                                
                                <div class="field">
                                    <?php echo $this->pageForm->meta_keywords;  ?>
                                    <div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($this->pageForm->meta_keywords->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                    <div class="input-errors" id="meta_keywords_err"></div>
                                </div>
                            </div>
                            
                            <div class="form-row">
                                <div class="label">
                                    <?php echo $this->pageForm->meta_desc->getLabel(); if($this->pageForm->meta_desc->isRequired()){ ?><span class="required">*</span><?php } ?>
                                </div>
                                
                                <div class="field">
                                    <?php echo $this->pageForm->meta_desc; ?>
                                    <div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($this->pageForm->meta_desc->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                    <div class="input-errors" id="meta_desc_err"></div>
                                </div>
                            </div>
                            
                        </div>
                   	</fieldset>
                    
                    <?php									
						$staticGroupsObj = $this->pageForm->getDisplayGroups();
						if($staticGroupsObj)
						{
							foreach($staticGroupsObj as $staticGroup)
							{
								$elementsObj = $staticGroup->getElements();
					?>
                    
                    	
					<fieldset class="fieldset last">
                        <legend class="legend"><?php echo $this->translator->translator($staticGroup->getAttrib('title')); ?></legend>
                        <div class="form">
                        	<?php																
								foreach($elementsObj as $element)
								{
									if($element->getAttrib('admin') == '1')
									{	
										if($element->getType() != 'Zend_Form_Element_File')
										{															
							?>
                            <div class="form-row">
                                <div class="label">
                                    <?php echo $element->getLabel(); if($element->isRequired() ){ ?><span class="<?php echo $this->escape($this->form_info['star_class']); ?>" style="<?php echo $this->escape($this->form_info['star_style']); ?>">*</span><?php } ?>
                                </div>
                                
                                <div class="field">
                                    <?php 										
											$id_f = $element->getAttrib('id');
											$id_arr = explode('_',$id_f);
											if(in_array('date',$id_arr))
											{
											?>
											<script type="text/javascript">
												$(function() {
													calender('<?php echo $id_f; ?>');
												});
											</script>
											<?php
											}
											echo $element;															
									?>
                                    <?php if($element->getAttrib('info')){ ?><div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($element->getAttrib('info')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div><?php } ?>
                                    <div class="input-errors" id="<?php echo $element->getName().'_err'; ?>"></div>
                                </div>
                            </div>
                            <?php
										}
									}
								}
							?>
						</div>
					</fieldset>
                    <?php
							}
						}
					?>
        </form>
	</div>
    
    <div class="button-container">
        <span class="button ui-widget-content-1"><a href="<?php echo $this->url( array('module' => 'News','controller' => 'Backendpro', 'action'     => 'list','group_id' => $param_group_id), 'adminrout',    true) ?>" class="back_btn_link"><span class="icon back"><?php echo $this->translator->translator('common_back'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript:  void(0);" class="reset_btn"><span class="icon reset"><?php echo $this->translator->translator('common_reset'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript: void(0);" class="edit_page_btn"><span class="icon save"><?php echo $this->translator->translator('common_save'); ?></span></a></span>
    </div>
</div>

<div id="floatingbar">
	<h1><?php echo $this->translator->translator('news_page_edit_page_name'); ?></h1>
    
    <div class="button-container">
        <span class="button ui-widget-content-1"><a href="<?php echo $this->url( array('module' => 'News','controller' => 'Backendpro', 'action'     => 'list','group_id' => $param_group_id), 'adminrout',    true) ?>" class="back_btn_link"><span class="icon back"><?php echo $this->translator->translator('common_back'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript:  void(0);" class="reset_btn"><span class="icon reset"><?php echo $this->translator->translator('common_reset'); ?></span></a></span>
        <span class="button ui-widget-content-1"><a href="javascript: void(0);" class="edit_page_btn"><span class="icon save"><?php echo $this->translator->translator('common_save'); ?></span></a></span>
    </div>
</div>

<?php endif; ?>

	<div id="dialog_msg" title="<?php echo $this->translator->translator('common_dialog_msg',$this->translator->translator('news_page_edit_page_name')); ?>"></div> 
	<div id="dialog_container" style="display:none" title="<?php echo $this->translator->translator('common_processing_language'); ?>">
		<div id="progressbar" ></div>	
	</div>

    <div id="upload-form" title="<?php echo $this->translator->translator('news_page_page_dialog'); ?>">
        <div>
        	<form id="popupForm" target="i-upload-form" method="post" action="" >
                <input type="hidden" name="table_name" value="news_group"/>
                <input type="hidden" name="primary_id_field" value="id"/>
                <input type="hidden" name="primary_id_field_value" value=""/>   
                <input type="hidden" name="primary_file_field" value="page_thumb"/> 
                <input type="hidden" name="file_content"  value=""/>       
                <input type="hidden" name="file_path_field" value="file_path_page_thumb"/>
                <input type="hidden" name="file_extension_field" value="img_type"/>
                <input type="hidden" name="file_max_size_field" value="file_size_max"/>
            </form>
            <iframe id="i-upload-form" name="i-upload-form" src="" class="iframe-article"></iframe>
        </div>
        
        <div class="button-container">
            <span class="button ui-widget-content-1"><a href="javascript:void(0);" class="select_file_btn"><span class="icon insert"><?php echo $this->translator->translator('news_page_page_insert'); ?></span></a></span>
            <span class="button ui-widget-content-1"><a href="javascript:void(0);" class="close_dialog_btn"><span class="icon close"><?php echo $this->translator->translator('common_close'); ?></span></a></span>
        </div>
    </div>
</div>